#! /bin/bash

cd /root/remote-ar-advertising
#拉取更新新代码
git pull origin master

#代码更新完后maven打包
mvn clean package -Dmaven.test.skip=true

#将jar 包 和Dockerfile复制到/root/ar-advertising
cp -rf /root/remote-ar-advertising/ar-advertising/target/*.jar /root/ar-advertising/ar-advertising.jar
cp -rf /root/remote-ar-advertising/ar-advertising/Dockerfile /root/ar-advertising/Dockerfile

#停止之前运行的容器
docker stop ar-advertising
#删除之前的容器
docker rm -f ar-advertising
#删除之前的镜像
docker rmi -f ar-advertising

#回到目录
cd /root/ar-advertising

#docker 构建镜像
docker build -t ar-advertising .
#docker 运行容器
docker run -d -p 9001:9001 --name ar-advertising ar-advertising



